package com.pianzhu.blockchainemr.controller;

import com.pianzhu.blockchainemr.pojo.*;
import com.pianzhu.blockchainemr.pojo.Param.EmpowerParam;
import com.pianzhu.blockchainemr.pojo.result.EmpowerResult;
import com.pianzhu.blockchainemr.pojo.result.MedicalRecordListResult;
import com.pianzhu.blockchainemr.pojo.result.MedicalReportListResult;
import com.pianzhu.blockchainemr.pojo.result.Result;
import com.pianzhu.blockchainemr.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;

    @GetMapping("/getHospitalList")
    public Result getHospitalList() {
        List<EmrHospital> hospitalList = patientService.getHospitalList();
        return Result.success(hospitalList);
    }

    @GetMapping("/getDeptList")
    public Result getDeptList() {
        List<EmrDeptDict> dictList = patientService.getDeptList();
        return Result.success(dictList);
    }

    @GetMapping("/getDoctorList")
    public Result getDoctorList(@RequestParam(name = "deptId") String deptId, @RequestParam(name = "hospitalId") Integer hospitalId) {
        List<EmrUser> doctorList = patientService.getDoctorList(deptId, hospitalId);
        return Result.success(doctorList);
    }

    @PostMapping("/appointment")
    public Result appointment(@RequestBody EmrMedVisit visit) {
        patientService.appointment(visit);
        return Result.success();
    }

    @GetMapping("/getMedicalRecordList")
    public Result getMedicalRecordList(@RequestParam(name = "username") String username) {
        List<MedicalRecordListResult> medicalRecordList = patientService.getMedicalRecordList(username);
        return Result.success(medicalRecordList);
    }

    @GetMapping("/getReportList")
    public Result getReportList(@RequestParam(name = "username") String username) {
        List<MedicalReportListResult> reportList = patientService.getReportList(username);
        return Result.success(reportList);
    }

    @GetMapping("/getEmpowerList")
    public Result getEmpowerList(@RequestHeader(name = "username") String username) {
        List<EmpowerResult> empowerList = patientService.getEmpowerList(username);
        return Result.success(empowerList);
    }

    @PostMapping("/updateEmpowerStatus")
    public Result updateEmpowerStatus(@RequestBody EmpowerParam empowerParam) {
        patientService.updateEmpowerStatus(empowerParam);
        return Result.success();
    }

    @GetMapping("/getCheckupList")
    public Result getCheckupList(@RequestHeader(name = "username") String username) {
        List<EmpowerResult> checkupList = patientService.getCheckupList(username);
        return Result.success(checkupList);
    }

    @PostMapping("/updateCheckupStatus")
    public Result updateCheckupStatus(@RequestBody EmpowerParam empowerParam) {
        patientService.updateCheckupStatus(empowerParam);
        return Result.success();
    }

    @GetMapping("/getMyPrescription")
    public Result getMyPrescription(@RequestHeader(name = "userId") String id) {
        List<EmrMedOrders> prescriptionList = patientService.getMyPrescription(id);
        return Result.success(prescriptionList);
    }

}
